#include <iostream>
#include <cstring>
using namespace std;

const int max_n = 120;

int sum_of_pile[max_n];

void construct(int pos) {
  int value;
  cin >> value;
  if (value == (-1)) {
    return;
  }
  sum_of_pile[pos] += value;
  construct(pos - 1);
  construct(pos + 1);
}

bool read_input() {
  int value;
  cin >> value;
  if (value == (-1)) {
    return false;
  }
  memset(sum_of_pile, 0, sizeof(sum_of_pile));
  int pos = max_n / 2;
  sum_of_pile[pos] = value;
  construct(pos - 1);
  construct(pos + 1);
  return true;
}

int main() {
  int kase = 0;
  while (read_input()) {
    int pos = 0;
    while (sum_of_pile[pos] == 0) {
      pos++;
    }
    cout << "Case " << ++kase << ":\n" << sum_of_pile[pos++];
    while (sum_of_pile[pos] != 0) {
      cout << " " << sum_of_pile[pos++];
    }
    cout << "\n\n";
  }
  
  return 0;
}
